package com.fa4j.third.sms.config;

import com.fa4j.third.base.config.ThirdAdapterConfigurer;
import com.fa4j.third.base.proxy.ThirdProxyFactoryBean;
import com.fa4j.third.base.service.ThirdConfigService;
import com.fa4j.third.sms.adapter.MockSmsServiceAdapter;
import com.fa4j.third.sms.service.ThirdSmsService;
import jakarta.validation.Validator;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;

import java.util.List;

@AutoConfiguration
public class ThirdSmsAutoConfiguration {

    @Bean
    public ThirdProxyFactoryBean<ThirdSmsService> thirdSmsService(ThirdConfigService thirdConfigService,
                                                                  List<ThirdAdapterConfigurer> configurers,
                                                                  Validator validator) {
        return new ThirdProxyFactoryBean<>(ThirdSmsService.class, thirdConfigService, configurers, validator);
    }

    @Bean
    public ThirdAdapterConfigurer mockSmsAdapterConfigurer() {
        return new ThirdAdapterConfigurer(MockSmsServiceAdapter.class);
    }
}
